<div id="banner_section">
	<div class="flexslider">
		<ul class="slides">
			<li>
				<img src="<?php echo base_url();?>uploads/images/banner_1.jpg" />
			</li>
			<li>
				<img src="<?php echo base_url();?>uploads/images/banner_2.jpg" />
			</li>
			<li>
				<img src="<?php echo base_url();?>uploads/images/banner_3.jpg" />
			</li>
		</ul>
	</div>
	<div class="promo_banner">
		<div class="home_banner"><a href="#"><img src="<?php echo base_url();?>uploads/images/promo_1.jpg"></a></div>
		<div class="home_banner"><a href="#"><img src="<?php echo base_url();?>uploads/images/promo_2.jpg"></a></div>
		<div class="home_banner"><a href="#"><img src="<?php echo base_url();?>uploads/images/promo_3.jpg"></a></div>
	</div>
</div>

<div class="products_list products_slider">
	<h2 class="sub_title">New Products</h2>
	<ul id="first-carousel" class="first-and-second-carousel jcarousel-skin-tango">
	<?php 
	if(sizeof($new_product) > 0){
		foreach ($new_product as $row){
	?>
		<li>
			<a class="product_image">
				<img src="<?php echo base_url();?>uploads/images/<?php echo $row->produk_sampul;?>" width=200 height=240 />
			</a>
			<div class="product_info">
				<h3><a href="#" onclick="view_singleproduct(<?php echo $row->produk_id;?>)"><?php echo $row->produk_nama;?></a></h3>
				<small><?php echo $row->produk_deskripsi;?></small> </div>
			<div class="price_info"> <a href="#">+ Add to wishlist</a>
				<button class="price_add" title="" type="button" onclick="addtocart(<?php echo $row->produk_id;?>)"><span class="pr_price">Rp. <?php echo number_format($row->produk_harga,0,',','.');?></span><span class="pr_add">Add to Cart</span></button>
			</div>
		</li>
	<?php 
		}
	}
	?>
	</ul>
</div>

<div class="products_list products_slider">
	<h2 class="sub_title">Offer Products</h2>
	<ul id="first-carousel" class="first-and-second-carousel jcarousel-skin-tango">
	<?php 
	if(sizeof($old_product) > 0){
		foreach ($old_product as $row){
	?>
		<li>
			<a class="product_image">
				<img src="<?php echo base_url();?>uploads/images/<?php echo $row->produk_sampul;?>" width=200 height=240 />
			</a>
			<div class="product_info">
				<h3><a href="#" onclick="view_singleproduct(<?php echo $row->produk_id;?>)"><?php echo $row->produk_nama;?></a></h3>
				<small><?php echo $row->produk_deskripsi;?></small> </div>
			<div class="price_info"> <a href="#">+ Add to wishlist</a>
				<button class="price_add" title="" type="button" onclick="addtocart(<?php echo $row->produk_id;?>)"><span class="pr_price">Rp. <?php echo number_format($row->produk_harga,0,',','.');?></span><span class="pr_add">Add to Cart</span></button>
			</div>
		</li>
	<?php 
		}
	}
	?>
	</ul>
</div>
<script language="javascript">
	var addtocart = null;
	var view_singleproduct = null;
</script>
<script type="text/javascript">
$(document).ready(function(){
	function addcart(pid){
		$.ajax({
			url : 'index.php/c_product/addtocart',
			type : 'POST',
			dataType : 'json',
			data : {
				pid : pid,
				q : '1'
			},success : function(data){
				var sum_item = $("#cart_sumitem").text();
				var sum_itemprice = $("#cart_sumprice").text();
				var list_item = $("#cart_listofitems").html();
				var new_sumitem = eval(sum_item) + 1;
				var new_sumitemprice = eval(sum_itemprice) + eval(data[0].produk_harga);
				var new_listitem = '<li><img width="82" height="82" src="<?php echo base_url(); ?>uploads/images/' + data[0].produk_sampul + '"><a href="#">' + data[0].produk_nama + '</a> <span class="price">Rp. ' + data[0].produk_harga + '</span></li>';
				$("#cart_sumitem").empty();
				$("#cart_sumprice").empty();
				$("#cart_listofitems").empty();
				$("#cart_subtotal").empty();
				$("#cart_sumitem").text(new_sumitem);
				$("#cart_sumprice").text(new_sumitemprice);
				$("#cart_listofitems").html(new_listitem + list_item);
				$("#cart_subtotal").text(new_sumitemprice);
			}
		});
	}
	addtocart = addcart;
	function update_topcart(){
		<?php 
		$sumitem = 0;
		$sumprice = 0;
		$list_item = '';
		if($produk !== ''){
			foreach($produk as $row_pd){
				$sumitem += $row_pd->qty;
				$sumprice += $row_pd->produk_harga * $row_pd->qty;
				$list_item .= '<li><img width="82" height="82" src="'. base_url() .'uploads/images/' . $row_pd->produk_sampul . '"><a href="#">' . $row_pd->produk_nama . '</a> <span class="price">Rp. ' . $row_pd->produk_harga . '</span></li>';
			}
		}	?>
		$("#cart_sumitem").empty();
		$("#cart_sumprice").empty();
		$("#cart_listofitems").empty();
		$("#cart_subtotal").empty();
		$("#cart_sumitem").text('<?php echo $sumitem; ?>');
		$("#cart_sumprice").text('<?php echo $sumprice; ?>');
		$("#cart_listofitems").html('<?php echo $list_item; ?>');
		$("#cart_subtotal").text('<?php echo $sumprice; ?>');
	}
	update_topcart();
	function view_singleproduk(pid){
		my_config.main.load('index.php/c_singleproduct?product_id=' + pid);
		return false;
	}
	view_singleproduct = view_singleproduk;
});
</script>